import { getDetailDataApi } from "../../utils/api";

// 详情模块
const detail = {
  namespaced: true,
  state: {
    // 详情相关
    detailInfo: {},
  },
  mutations: {
    // 改变详情数据
    getDetailInfo(state, payload) {
      state.detailInfo = payload;
    },
  },
  actions: {
    // 详情接口
    async getDetailInfoAsync({ commit }, payload) {
      const res = await getDetailDataApi({
        id: payload.id,
      });
      if (res.status === 0) {
        commit("getDetailInfo", res.result);
      }
    },
  },
};

export default detail;
